package com.mchsdk.paysdk.bean;


import android.content.Context;
import android.content.Intent;

import com.mchsdk.open.OrderInfo;
import com.mchsdk.open.PayCallback;
import com.mchsdk.paysdk.activity.MCChoosePayActivity;
import com.mchsdk.paysdk.config.MCHConstant;
import com.mchsdk.paysdk.utils.MCLog;
import com.mchsdk.paysdk.utils.TextUtils;
import com.mchsdk.paysdk.utils.ToastUtil;

/**
 * An example full-screen activity that shows and hides the system UI (i.e.
 * status bar and navigation/system bar) with user interaction.
 *
 */
public class MCPayModel {

	/**
	 * 日志打印
	 */
	private final static String TAG = "MCPayModel";

	private PayCallback pck;
	private OrderInfo currentOrderInfo = null;

	private static MCPayModel payModel;

	public static MCPayModel Instance(){
		if(null == payModel){
			payModel = new MCPayModel();
		}
		return payModel;
	}

	private MCPayModel() {
	}

	/**
	 * 商品支付
	 * @param orderInfo 商品信息
	 * @param pck 支付回调
	 */
	public void pay(Context context, OrderInfo orderInfo, PayCallback pck) {
		if (!ChannelAndGameInfo.getInstance().haveReadGameInfo()) {
			ToastUtil.show(context, "渠道信息异常");
			return;
		}
		this.pck = pck;
		currentOrderInfo = orderInfo;

		if(TextUtils.isEmpty(PersonalCenterModel.getInstance().getUserId())){
//			MCLog.e(TAG, "用户未登录");
			ToastUtil.show(context,"用户未登录");
			return;
		}

		Intent intent = new Intent(context, MCChoosePayActivity.class);
		context.startActivity(intent);

//		int theme = MCHInflaterUtils.getIdByName(gamecon, "style", "ChoosePayDialog");
//		LoadingDialog.dialog = new LoadingDialog(gamecon,theme);
//		LoadingDialog.dialog.setCanceledOnTouchOutside(false);
//		LoadingDialog.dialog.setCancelable(false);
//		DialogUtil.setDialog(LoadingDialog.dialog);
//		LoadingDialog.dialog.show();
	}

   public OrderInfo order(){
	   return currentOrderInfo;
   }


	public PayCallback getPck() {
		return pck;
	}
}
